Imports System.Data.SqlClient

Friend Class DBVText_Factory
    Inherits DBBase

    Public Sub ClearText( _
        ByVal lViewID As Long, _
        ByVal lViewRevID As Long)

        Dim sSQL As String = "delete from tDDViewText"
        sSQL = sSQL & " where"
        sSQL = sSQL & "   [ViewID]=" & lViewID
        sSQL = sSQL & "   and [ViewRevID]=" & lViewRevID

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Sub AddText( _
        ByVal lViewID As Long, _
        ByVal lViewRevID As Long, _
        ByVal iOrder As Integer, _
        ByVal sText As String)

        Dim sSQL As String = "insert into tDDViewText ("
        sSQL = sSQL & " [ViewID],"
        sSQL = sSQL & " [ViewRevID],"
        sSQL = sSQL & " [Order],"
        sSQL = sSQL & " [Text]) values ("
        sSQL = sSQL & lViewID & ","
        sSQL = sSQL & lViewRevID & ","
        sSQL = sSQL & iOrder & ","
        sSQL = sSQL & ValueToDBValue(sText) & ")"

        MyBase.ExecuteNonQuery(sSQL)
    End Sub

    Public Function GetText( _
        ByVal lViewID As Long, _
        ByVal lViewRevID As Long) As String

        Dim sText As String = ""

        Dim sSQL As String = "select"
        sSQL = sSQL & "     [Text]"
        sSQL = sSQL & " from"
        sSQL = sSQL & "     tDDViewText a"
        sSQL = sSQL & " where"
        sSQL = sSQL & "     [ViewID]=" & ValueToDBValue(lViewID)
        sSQL = sSQL & "     and [ViewRevID]=" & ValueToDBValue(lViewRevID)
        sSQL = sSQL & " order by"
        sSQL = sSQL & "     [Order]"

        Dim oData As DataTable = MyBase.ExecuteReadToDataTable(sSQL)

        For Each oRow As DataRow In oData.Rows
            sText = sText & oRow.Item(0)
        Next

        oData.Dispose()

        Return sText
    End Function
End Class
